package com.jaychen.tliaswebmanagement.mapper;

import com.github.pagehelper.Page;
import com.jaychen.tliaswebmanagement.pojo.ClassQueryParam;
import com.jaychen.tliaswebmanagement.pojo.Clazz;
import lombok.Data;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface ClazzMapper {

    Page list(ClassQueryParam classQueryParam);

    @Insert("insert into clazz(name, room, begin_date, end_date," +
            " master_id, subject, create_time, update_time)" +
            "values (#{name},#{room},#{beginDate},#{endDate}," +
            "#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    @Delete("delete from clazz where id = #{id}")
    void delete(Integer id);

    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time" +
            " from clazz where id = #{id}")
    Clazz getById(Integer id);

    void update(Clazz clazz);

    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time " +
            "from clazz")
    List<Clazz> getAll();
}
